package com.scau.ums.controller;

import com.github.pagehelper.PageInfo;
import com.scau.ums.mapper.RepairreportMapper;
import com.scau.ums.model.Repairreport;
import com.scau.ums.service.imp.RepairReport.RepairReportImp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class ReadFinishedReportController {

    @Autowired
    private RepairReportImp repairReportImp;
    @Autowired
    private RepairreportMapper repairReportMapper;

    @RequestMapping("showAllFinishedReport")
    public String showAllFinishedReport(HttpServletRequest request, @RequestParam(value = "currentPage",required=false,defaultValue="1")Integer currentPage){
        List<Repairreport> repairReportList = repairReportImp.getAllFinishedReport(currentPage);
        PageInfo<Repairreport> pageInfo= new PageInfo<Repairreport>(repairReportList);

        request.setAttribute("repairReportList",repairReportList);
        request.setAttribute("pageInfo",pageInfo);
        return "showAllFinishedReport";
    }

    @RequestMapping("showSpecifiedReport")
    public String showSpecifiedReport(HttpServletRequest request,int reportId){
        Repairreport repairReport = repairReportMapper.selectByPrimaryKey(reportId);
        request.setAttribute("repairReport",repairReport);
        return "showSpecifiedReport";
    }
}
